#include <gtest/gtest.h>

static int tfoo( int a, int b );

int main( int argc, char *argv[] )
{
	testing::InitGoogleTest( &argc, argv );
	return RUN_ALL_TESTS();
}

TEST( FooTest, HandleNoneZeroInput ){
	EXPECT_EQ( 2, tfoo( 4, 10 ));
	EXPECT_EQ( 6, tfoo( 30, 18 ));
}

static int tfoo( int a, int b )
{
	if( a == 0 || b == 0 )
		return -1;
	int c = a % b;
	if( c == 0 )
		return b;

	return tfoo( b, c );
}
